<?php
/**
 * 促销页面
 *
 */
defined('InShopNC') or exit('Access Invalid!');
class double_tenControl extends MobileControl{
	public function __construct() {
		/**
		 * 设置模板文件夹路径
		 */
		Tpl::setDir ( 'activities' );
	}
    public function indexOp() {
		showMessage('亲！您来晚了，商品已被抢购完了~','index.php', null, 'error');
		//一元抢商品
		$sql = "SELECT * FROM #__goods WHERE goods_activite_flag = ".GOODS_ACTIVITE_FLAG_ONEROB;
		$onerobList=DB::queryAll($sql);
		foreach ($onerobList as $_k => $_v) {
			$sql = "SELECT B.discount FROM #__p_xianshi_goods as A 
					LEFT JOIN #__p_xianshi as B
					ON A.xianshi_id= B.xianshi_id
					WHERE A.goods_id =".$_v['goods_id'] ." AND end_time > ".time();
			$xianshi=DB::queryRow($sql);
			if(empty($xianshi)) $xianshi['discount']=10;
			$onerobList[$_k]['xianshi_discount']	=$xianshi['discount']/10;
		}
		//半价购商品
		$sql = "SELECT * FROM #__goods WHERE goods_activite_flag = ".GOODS_ACTIVITE_FLAG_HALF;
		$halfList=DB::queryAll($sql);
		foreach ($halfList as $_k => $_v) {
			$sql = "SELECT B.discount FROM #__p_xianshi_goods as A 
					LEFT JOIN #__p_xianshi as B
					ON A.xianshi_id= B.xianshi_id
					WHERE A.goods_id =".$_v['goods_id'] ." AND end_time > ".time();
			$xianshi=DB::queryRow($sql);
			if(empty($xianshi)) $xianshi['discount']=10;
			$halfList[$_k]['xianshi_discount']	=$xianshi['discount']/10;	
		}
		Tpl::output('onerobList', $onerobList);
		Tpl::output('halfList', $halfList);
		Tpl::showpage('double_ten');
	}
}